﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using System.Data.SqlClient;
using System.IO;

namespace Quanlybanhang
{
    public partial class MainForm : Office2007RibbonForm
    {
        public static SqlConnection con;
        String Connection_String = "";
        ConnectionForm cndb = new ConnectionForm();

        public MainForm()
        {
            InitializeComponent();
            GetConnectionString();
        }

        public void GetConnectionString()
        {
            StreamReader sr = new StreamReader(Application.StartupPath + "\\configuration.db");
            Connection_String = sr.ReadLine();
            ketnoi();
        }

        public void ketnoi()
        {
            try
            {
                con = new SqlConnection();
                con.ConnectionString = Connection_String;
                con.Open();
            }
            catch (Exception e)
            {
                MessageBox.Show("Không thể kết nối CSDL", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                e.ToString();
            }
        }

        //ok
        private void btnMuavao_Click(object sender, EventArgs e)
        {
            MuavaoForm muavao = new MuavaoForm();
            muavao.MdiParent = MainForm.ActiveForm;
            muavao.Show();
            muavao.WindowState = FormWindowState.Maximized;
        }

        //ok
        private void btnBanra_Click(object sender, EventArgs e)
        {
            BanraForm banra = new BanraForm();
            banra.MdiParent = MainForm.ActiveForm;
            banra.Show();
            banra.WindowState = FormWindowState.Maximized;
        }

        //ok
        private void btnChubanhang_Click(object sender, EventArgs e)
        {
            Chubanhang chuban = new Chubanhang();
            chuban.MdiParent = MainForm.ActiveForm;
            chuban.Show();
            chuban.WindowState = FormWindowState.Maximized;
        }

        //ok
        private void btnThemChuban_Click(object sender, EventArgs e)
        {
            ThemchubanForm themchuban = new ThemchubanForm();
            themchuban.MdiParent = MainForm.ActiveForm;
            themchuban.Show();
            themchuban.WindowState = FormWindowState.Maximized;
        }
        //ok
        private void btnSearchChuban_Click(object sender, EventArgs e)
        {
            TimkiemChubanForm timchuban = new TimkiemChubanForm();
            timchuban.MdiParent = MainForm.ActiveForm;
            timchuban.Show();
            timchuban.WindowState = FormWindowState.Maximized;
        }
        //ok
        private void btnChuhangmua_Click(object sender, EventArgs e)
        {
            Chuhangmua chuhangmua = new Chuhangmua();
            chuhangmua.MdiParent = MainForm.ActiveForm;
            chuhangmua.Show();
            chuhangmua.WindowState = FormWindowState.Maximized;
        }

        //ok
        private void btnAddChuhangmua_Click(object sender, EventArgs e)
        {
            ThemchumuaForm themchumua = new ThemchumuaForm();
            themchumua.MdiParent = MainForm.ActiveForm;
            themchumua.Show();
            themchumua.WindowState = FormWindowState.Maximized;
        }


        //ok
        private void btnSearchChuhangmua_Click(object sender, EventArgs e)
        {
            TimkiemChumuaForm timchumua = new TimkiemChumuaForm();
            timchumua.MdiParent = MainForm.ActiveForm;
            timchumua.Show();
            timchumua.WindowState = FormWindowState.Maximized;
        }

        //ok
        private void btnThunghang_Click(object sender, EventArgs e)
        {
            DonviForm donvi = new DonviForm();
            donvi.MdiParent = MainForm.ActiveForm;
            donvi.Show();
            donvi.WindowState = FormWindowState.Maximized;
        }

        //ok
        private void btnGiaban_Click(object sender, EventArgs e)
        {
            GiabanForm gia = new GiabanForm();
            gia.MdiParent = MainForm.ActiveForm;
            gia.Show();
            gia.WindowState = FormWindowState.Maximized;
        }

        private void btnThongkemuaban_Click(object sender, EventArgs e)
        {
            Thongke_luutru luu = new Thongke_luutru();
            luu.MdiParent = MainForm.ActiveForm;
            luu.Show();
            luu.WindowState = FormWindowState.Maximized;
        }
    }
}
